package com.upb.webserver.dao.mapper;

import com.upb.webserver.dao.entity.TbContract;
import com.upb.webserver.dao.entity.TbContractExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

@Deprecated
public interface TbContractMapper {

    @Delete({ "delete from tb_contract", "where chain_id = #{chainId,jdbcType=INTEGER}" })
    int deleteByChainId(@Param("chainId") Integer chainId);

    @Select({ "select", TbContractSqlProvider.ALL_COLUMN_FIELDS, "from tb_contract", "where application_id = #{appId,jdbcType=INTEGER} and  name = #{name,jdbcType=VARCHAR}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "remote_id", property = "remoteId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "application_id", property = "applicationId", jdbcType = JdbcType.INTEGER), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "contract_type", property = "contractType", jdbcType = JdbcType.TINYINT), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    TbContract selectByApplicationAndName(@Param("appId") Integer appId, @Param("name") String name);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbContractSqlProvider.class, method = "countByExample")
    long countByExample(TbContractExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbContractSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbContractExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_contract", "where id = #{id,jdbcType=INTEGER}" })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_contract (remote_id, chain_id, ", "application_id, name, ", "contract_type, chain_type, ", "address, status, ", "create_time, modify_time)", "values (#{remoteId,jdbcType=INTEGER}, #{chainId,jdbcType=INTEGER}, ", "#{applicationId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ", "#{contractType,jdbcType=TINYINT}, #{chainType,jdbcType=TINYINT}, ", "#{address,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, ", "#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})" })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insert(TbContract record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbContractSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insertSelective(TbContract record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbContractSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "remote_id", property = "remoteId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "application_id", property = "applicationId", jdbcType = JdbcType.INTEGER), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "contract_type", property = "contractType", jdbcType = JdbcType.TINYINT), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    List<TbContract> selectByExample(TbContractExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @Select({ "select", "id, remote_id, chain_id, application_id, name, contract_type, chain_type, address, ", "status, create_time, modify_time", "from tb_contract", "where id = #{id,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "remote_id", property = "remoteId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "application_id", property = "applicationId", jdbcType = JdbcType.INTEGER), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "contract_type", property = "contractType", jdbcType = JdbcType.TINYINT), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    TbContract selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbContractSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbContract record, @Param("example") TbContractExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbContractSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbContract record, @Param("example") TbContractExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbContractSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbContract record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @Update({ "update tb_contract", "set remote_id = #{remoteId,jdbcType=INTEGER},", "chain_id = #{chainId,jdbcType=INTEGER},", "application_id = #{applicationId,jdbcType=INTEGER},", "name = #{name,jdbcType=VARCHAR},", "contract_type = #{contractType,jdbcType=TINYINT},", "chain_type = #{chainType,jdbcType=TINYINT},", "address = #{address,jdbcType=VARCHAR},", "status = #{status,jdbcType=TINYINT},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "modify_time = #{modifyTime,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKey(TbContract record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert({ "<script>", "insert into tb_contract (remote_id, ", "chain_id, application_id, ", "name, contract_type, ", "chain_type, address, ", "status, create_time, ", "modify_time)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.remoteId,jdbcType=INTEGER}, ", "#{detail.chainId,jdbcType=INTEGER}, #{detail.applicationId,jdbcType=INTEGER}, ", "#{detail.name,jdbcType=VARCHAR}, #{detail.contractType,jdbcType=TINYINT}, ", "#{detail.chainType,jdbcType=TINYINT}, #{detail.address,jdbcType=VARCHAR}, ", "#{detail.status,jdbcType=TINYINT}, #{detail.createTime,jdbcType=TIMESTAMP}, ", "#{detail.modifyTime,jdbcType=TIMESTAMP})</foreach></script>" })
    int batchInsert(List<TbContract> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_contract
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbContractSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "remote_id", property = "remoteId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "application_id", property = "applicationId", jdbcType = JdbcType.INTEGER), @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR), @Result(column = "contract_type", property = "contractType", jdbcType = JdbcType.TINYINT), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR), @Result(column = "status", property = "status", jdbcType = JdbcType.TINYINT), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    Optional<TbContract> getOneByExample(TbContractExample example);
}
